package com.avamanager.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.avamanager.common.annotation.Log;
import com.avamanager.common.core.controller.BaseController;
import com.avamanager.common.core.domain.AjaxResult;
import com.avamanager.common.enums.BusinessType;
import com.avamanager.app.domain.AppStudentPlace;
import com.avamanager.app.service.IAppStudentPlaceService;
import com.avamanager.common.utils.poi.ExcelUtil;
import com.avamanager.common.core.page.TableDataInfo;

/**
 * 学籍信息Controller
 * 
 * @author FenvyYe
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/app/student_place")
public class AppStudentPlaceController extends BaseController
{
    @Autowired
    private IAppStudentPlaceService appStudentPlaceService;

    /**
     * 查询学籍信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppStudentPlace appStudentPlace)
    {
        startPage();
        List<AppStudentPlace> list = appStudentPlaceService.selectAppStudentPlaceList(appStudentPlace);
        return getDataTable(list);
    }

    /**
     * 导出学籍信息列表
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:export')")
    @Log(title = "学籍信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppStudentPlace appStudentPlace)
    {
        List<AppStudentPlace> list = appStudentPlaceService.selectAppStudentPlaceList(appStudentPlace);
        ExcelUtil<AppStudentPlace> util = new ExcelUtil<AppStudentPlace>(AppStudentPlace.class);
        util.exportExcel(response, list, "学籍信息数据");
    }

    /**
     * 获取学籍信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:query')")
    @GetMapping(value = "/{studentPlaceId}")
    public AjaxResult getInfo(@PathVariable("studentPlaceId") Long studentPlaceId)
    {
        return AjaxResult.success(appStudentPlaceService.selectAppStudentPlaceByStudentPlaceId(studentPlaceId));
    }

    /**
     * 新增学籍信息
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:add')")
    @Log(title = "学籍信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppStudentPlace appStudentPlace)
    {
        return toAjax(appStudentPlaceService.insertAppStudentPlace(appStudentPlace));
    }

    /**
     * 修改学籍信息
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:edit')")
    @Log(title = "学籍信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppStudentPlace appStudentPlace)
    {
        return toAjax(appStudentPlaceService.updateAppStudentPlace(appStudentPlace));
    }

    /**
     * 删除学籍信息
     */
    @PreAuthorize("@ss.hasPermi('app:student_place:remove')")
    @Log(title = "学籍信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studentPlaceIds}")
    public AjaxResult remove(@PathVariable Long[] studentPlaceIds)
    {
        return toAjax(appStudentPlaceService.deleteAppStudentPlaceByStudentPlaceIds(studentPlaceIds));
    }
}
